﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Masters/WithoutPermBasic.Master" AutoEventWireup="true" CodeBehind="InvoiceInfo.aspx.cs" Inherits="PMS.UI.FM.InvoiceInfo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        var height = $("#divTotal").height();
        var content = parseFloat(height) - 30;
        $("#tbList").css("height", content);
        method = com.get.method;
        invoiceID = com.get.Id;
        $(function () {
            if (method == "look") {
                $("a.easyui-linkbutton").linkbutton('disable')
            };
            if (method == "add") {
                $("#Date").datebox('setValue', datetools.day(new Date()))
            } else {
                com.ajax({
                    url: "/Logic/FM/InvoiceAjax.aspx?method=GetInvoiceById",
                    data: { "Id": invoiceID },
                    success: function (data) {
                        $("#form1").form("load", data);
                        $("#TaxpayerID").val(data.TaxpayerID);
                        $("#Bank").val(data.Bank);
                        $("#BankAccount").val(data.BankAccount);
                        $("#BankAccount").val(data.BankAccount);
                        $("#Code").val(data.Code)
                    }
                });
            }

            $("#ContractID").combogrid({
                delay: 500,
                mode: 'remote',
                url: '/Logic/CM/ContractAjax.aspx?method=GetAllContract',
                idField: 'ID',
                textField: 'ContractName',
                panelWidth: 344,
                columns: [[
                {
                    field: 'ID', title: 'ID', width: 40, align: 'center'
                },
                {
                    field: 'ContractName', title: '合同名称', width: 120
                },
                {
                    field: 'Code', title: '合同编号', width: 120
                },
                {
                    field: 'ContractMoney', title: '合同金额', width: 60
                }
                ]],
                onSelect: function (rowindex, rowData) {
                    $('#Code').val(rowData.Code);
                    $('#CompanyID').combogrid('setValue', rowData.CustomerID);
                    var g = $('#CompanyID').combogrid('grid');
                    g.datagrid('selectRecord', rowData.CustomerID);
                    var row = g.datagrid('getSelected');
                    $('#TaxpayerID').val(row.TaxpayerID);
                    $('#Bank').val(row.Bank);
                    $('#BankAccount').val(row.BankAccount)
                }
            });

            $("#CompanyID").combogrid({
                url: '/Logic/BD/CompanyAjax.aspx?method=GetAllCompanyInfo',
                delay: 500,
                mode: 'remote',
                idField: 'ID',
                textField: 'ComName',
                panelWidth: 524,
                columns: [[
                {
                    field: 'ID', title: 'ID', width: 40, align: 'center'
                },
                {
                    field: 'ComName', title: '客户名称', width: 120
                },
                {
                    field: 'TaxpayerID', title: '纳税人识别号', width: 120
                },
                {
                    field: 'Bank', title: '开户银行', width: 120
                },
                {
                    field: 'BankAccount', title: '账户', width: 120
                }
                ]],
                onSelect: function (rowindex, rowData) {
                    $('#TaxpayerID').val(rowData.TaxpayerID);
                    $('#Bank').val(rowData.Bank);
                    $('#BankAccount').val(rowData.BankAccount)
                }
            })
        })
    </script>

    <script type="text/javascript">

        function funcSave() {
            var g1 = $('#CompanyID').combogrid('grid');
            var company = g1.datagrid('getSelected');
            var g2 = $('#ContractID').combogrid('grid');
            var contract = g2.datagrid('getSelected');
            if (null != contract || null != company) {
                if ($("#form1").form('validate')) {
                    var getUrl = "/Logic/FM/InvoiceAjax.aspx?method=";
                    if (method == "add") {
                        getUrl += "AddInvoice"
                    } else {
                        getUrl += "EditInvoice"
                    }
                    com.ajax({
                        url: getUrl,
                        data: com.serializeObj("form1"),
                        success: function (data) {
                            com.message(data.state, data.msg, function () { top.wrapper.tabClosethisRefreshByTitle('开票信息') });
                        }
                    })
                }
            } else {
                com.message("information", "请选择客户或合同！");
            }
        }

    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
    <div id="InvoiceInfo" style="overflow: auto; padding: 20px; height: 96%; width: 96%">
        <div id="divToobar" style="background-color: #EFEFEF; overflow: visible">
            <a href="javascript:void(0)" id="btnSave" class="easyui-linkbutton" onclick="funcSave()"
                data-options="iconCls:'icon-save',plain:true">保存</a> &nbsp;&nbsp;
        </div>
        <div class="container_16" style="height: auto">
            <form id="form1">
                <div id="title" class="grid_16" style="text-align: center">
                    <h1>发票信息</h1>
                    <input type="hidden" id="ID" name="ID" />
                </div>
                <div class="grid_16">
                    <hr style="width: 102%; margin-left: 25px" />
                </div>
                <div class="grid_4 lbl" style="text-align: right;">
                    客户名称 :
                </div>
                <div class="grid_4 val" style="text-align: left;">
                    <input type="text" id="CompanyID" name="CompanyID" />
                </div>
                <div class="grid_4 lbl" style="text-align: right;">
                    纳税人识别号 :
                </div>
                <div class="grid_4 val" style="text-align: left;">
                    <input type="text" id="TaxpayerID" readonly="readonly" />
                </div>
                <div class="grid_4 lbl" style="text-align: right;">
                    开户银行 :
                </div>
                <div class="grid_4 val" style="text-align: left;">
                    <input type="text" id="Bank" readonly="readonly" />
                </div>
                <div class="grid_4 lbl" style="text-align: right;">
                    账户 :
                </div>
                <div class="grid_4 val" style="text-align: left;">
                    <input type="text" id="BankAccount" readonly="readonly" />
                </div>
                <div class="grid_16">
                    <hr style="width: 100%; margin-left: 25px" />
                </div>
                <div class="grid_4 lbl" style="text-align: right;">
                    合同名 :
                </div>
                <div class="grid_4 val" style="text-align: left;">
                    <input type="text" id="ContractID" name="ContractID" />
                </div>
                <div class="grid_4 lbl" style="text-align: right;">
                    合同编号 :
                </div>
                <div class="grid_4 val" style="text-align: left;">
                    <input type="text" id="Code" readonly="readonly" />
                </div>
                <div class="grid_16">
                    <hr style="width: 100%; margin-left: 25px" />
                </div>
                <div class="grid_4 lbl" style="text-align: right;">
                    发票编号 :
                </div>
                <div class="grid_4 val" style="text-align: left;">
                    <input type="text" class="easyui-validatebox" id="InvoiceNo" name="InvoiceNo" data-options="required:true" />
                </div>
                <div class="grid_4 lbl" style="text-align: right;">
                    发票名称 :
                </div>
                <div class="grid_4 val" style="text-align: left;">
                    <input type="text" id="InvoiceName" name="InvoiceName" class="easyui-validatebox" data-options="validateType:'length[0,100]'" />
                </div>
                <div class="grid_4 lbl" style="text-align: right;">
                    发票金额 :
                </div>
                <div class="grid_4 val" style="text-align: left;">
                    <input type="text" class="easyui-numberbox" id="Money" name="Money" data-options="min:0,precision:2" />
                </div>
                <div class="grid_4 lbl" style="text-align: right;">
                    开票日期 :
                </div>
                <div class="grid_4 val" style="text-align: left;">
                    <input type="text" class="easyui-datebox" id="Date" name="Date" />
                </div>
                <div class="Clear"></div>
                <div class="grid_4 lbl" style="text-align: right;">
                    备注 :
                </div>
                <div class="grid_4 val" style="text-align: left;">
                    <input type="text" class="easyui-textbox" id="Note" name="Note" data-options="validateType:'length[0,250]'" />
                </div>
            </form>
        </div>
    </div>

</asp:Content>



